using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;

using SharpCore.Data;

namespace TF.Access {
	public partial class TF_EventH {
		#region Fields
		private int id;
		private string eventTitle;
		private DateTime startDate = System.Data.SqlTypes.SqlDateTime.MinValue.Value;
		private DateTime endDate = System.Data.SqlTypes.SqlDateTime.MinValue.Value;
		private int dueDays;
		private string memo;
		private string picUrl;
		private int ownerId;
		private DateTime createDate = System.Data.SqlTypes.SqlDateTime.MinValue.Value;
		private double totalCost;
		private int attendCount;
		private int starNum;
		private string publicType;
		private int startCityId;
		private string eventCities;
		private int attentionCount;
		#endregion
		
		#region Constructors
		/// <summary>
		/// Initializes a new instance of the TF_EventH class.
		/// </summary>
		public TF_EventH() {
		}
		
		/// <summary>
		/// Initializes a new instance of the TF_EventH class.
		/// </summary>
		public TF_EventH(string eventTitle, DateTime startDate, DateTime endDate, int dueDays, string memo, string picUrl, int ownerId, DateTime createDate, double totalCost, int attendCount, int starNum, string publicType, int startCityId, string eventCities, int attentionCount) {
			this.eventTitle = eventTitle;
			this.startDate = startDate;
			this.endDate = endDate;
			this.dueDays = dueDays;
			this.memo = memo;
			this.picUrl = picUrl;
			this.ownerId = ownerId;
			this.createDate = createDate;
			this.totalCost = totalCost;
			this.attendCount = attendCount;
			this.starNum = starNum;
			this.publicType = publicType;
			this.startCityId = startCityId;
			this.eventCities = eventCities;
			this.attentionCount = attentionCount;
		}
		
		/// <summary>
		/// Initializes a new instance of the TF_EventH class.
		/// </summary>
		public TF_EventH(int id, string eventTitle, DateTime startDate, DateTime endDate, int dueDays, string memo, string picUrl, int ownerId, DateTime createDate, double totalCost, int attendCount, int starNum, string publicType, int startCityId, string eventCities, int attentionCount) {
			this.id = id;
			this.eventTitle = eventTitle;
			this.startDate = startDate;
			this.endDate = endDate;
			this.dueDays = dueDays;
			this.memo = memo;
			this.picUrl = picUrl;
			this.ownerId = ownerId;
			this.createDate = createDate;
			this.totalCost = totalCost;
			this.attendCount = attendCount;
			this.starNum = starNum;
			this.publicType = publicType;
			this.startCityId = startCityId;
			this.eventCities = eventCities;
			this.attentionCount = attentionCount;
		}
		#endregion
		
		#region Properties
		/// <summary>
		/// Gets or sets the Id value.
		/// </summary>
		public int Id {
			get { return id; }
			set { id = value; }
		}
		
		/// <summary>
		/// Gets or sets the EventTitle value.
		/// </summary>
		public string EventTitle {
			get { return eventTitle; }
			set { eventTitle = value; }
		}
		
		/// <summary>
		/// Gets or sets the StartDate value.
		/// </summary>
		public DateTime StartDate {
			get { return startDate; }
			set { startDate = value; }
		}
		
		/// <summary>
		/// Gets or sets the EndDate value.
		/// </summary>
		public DateTime EndDate {
			get { return endDate; }
			set { endDate = value; }
		}
		
		/// <summary>
		/// Gets or sets the DueDays value.
		/// </summary>
		public int DueDays {
			get { return dueDays; }
			set { dueDays = value; }
		}
		
		/// <summary>
		/// Gets or sets the Memo value.
		/// </summary>
		public string Memo {
			get { return memo; }
			set { memo = value; }
		}
		
		/// <summary>
		/// Gets or sets the PicUrl value.
		/// </summary>
		public string PicUrl {
			get { return picUrl; }
			set { picUrl = value; }
		}
		
		/// <summary>
		/// Gets or sets the OwnerId value.
		/// </summary>
		public int OwnerId {
			get { return ownerId; }
			set { ownerId = value; }
		}
		
		/// <summary>
		/// Gets or sets the CreateDate value.
		/// </summary>
		public DateTime CreateDate {
			get { return createDate; }
			set { createDate = value; }
		}
		
		/// <summary>
		/// Gets or sets the TotalCost value.
		/// </summary>
		public double TotalCost {
			get { return totalCost; }
			set { totalCost = value; }
		}
		
		/// <summary>
		/// Gets or sets the AttendCount value.
		/// </summary>
		public int AttendCount {
			get { return attendCount; }
			set { attendCount = value; }
		}
		
		/// <summary>
		/// Gets or sets the StarNum value.
		/// </summary>
		public int StarNum {
			get { return starNum; }
			set { starNum = value; }
		}
		
		/// <summary>
		/// Gets or sets the PublicType value.
		/// </summary>
		public string PublicType {
			get { return publicType; }
			set { publicType = value; }
		}
		
		/// <summary>
		/// Gets or sets the StartCityId value.
		/// </summary>
		public int StartCityId {
			get { return startCityId; }
			set { startCityId = value; }
		}
		
		/// <summary>
		/// Gets or sets the EventCities value.
		/// </summary>
		public string EventCities {
			get { return eventCities; }
			set { eventCities = value; }
		}
		
		/// <summary>
		/// Gets or sets the AttentionCount value.
		/// </summary>
		public int AttentionCount {
			get { return attentionCount; }
			set { attentionCount = value; }
		}
		#endregion
		
		#region Methods
		/// <summary>
		/// Saves a record to the TF_EventH table.
		/// </summary>
		public void Insert() {
			id = Convert.ToInt32(SqlClientUtility.ExecuteScalar("TF_EventHInsert", eventTitle, startDate, endDate, dueDays, memo, picUrl, ownerId, createDate, totalCost, attendCount, starNum, publicType, startCityId, eventCities, attentionCount));
		}
		
		/// <summary>
		/// Updates a record in the TF_EventH table.
		/// </summary>
		public void Update() {
			SqlClientUtility.ExecuteNonQuery("TF_EventHUpdate", id, eventTitle, startDate, endDate, dueDays, memo, picUrl, ownerId, createDate, totalCost, attendCount, starNum, publicType, startCityId, eventCities, attentionCount);
		}
		
		/// <summary>
		/// Deletes a record from the TF_EventH table by its primary key.
		/// </summary>
		public void Delete() {
			SqlClientUtility.ExecuteNonQuery("TF_EventHDelete", id);
		}
		
		/// <summary>
		/// Selects a single record from the TF_EventH table.
		/// </summary>
		public static TF_EventH Select(int id) {
			using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader("TF_EventHSelect", id)) {
				if (dataReader.Read()) {
					return MakeTF_EventH(dataReader);
				} else {
					return null;
				}
			}
		}
		
		/// <summary>
		/// Selects all records from the TF_EventH table.
		/// </summary>
		public static List<TF_EventH> SelectAll() {
			using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader("TF_EventHSelectAll")) {
				List<TF_EventH> tF_EventHList = new List<TF_EventH>();
				while (dataReader.Read()) {
					TF_EventH tF_EventH = MakeTF_EventH(dataReader);
					tF_EventHList.Add(tF_EventH);
				}
				return tF_EventHList;
			}
		}
		
		/// <summary>
		/// Creates a new instance of the TF_EventH class and populates it with data from the specified SqlDataReader.
		/// </summary>
		private static TF_EventH MakeTF_EventH(SqlDataReader dataReader) {
			TF_EventH tF_EventH = new TF_EventH();
			
			if (dataReader.IsDBNull(0) == false) {
				tF_EventH.Id = dataReader.GetInt32(0);
			}
			if (dataReader.IsDBNull(1) == false) {
				tF_EventH.EventTitle = dataReader.GetString(1);
			}
			if (dataReader.IsDBNull(2) == false) {
				tF_EventH.StartDate = dataReader.GetDateTime(2);
			}
			if (dataReader.IsDBNull(3) == false) {
				tF_EventH.EndDate = dataReader.GetDateTime(3);
			}
			if (dataReader.IsDBNull(4) == false) {
				tF_EventH.DueDays = dataReader.GetInt32(4);
			}
			if (dataReader.IsDBNull(5) == false) {
				tF_EventH.Memo = dataReader.GetString(5);
			}
			if (dataReader.IsDBNull(6) == false) {
				tF_EventH.PicUrl = dataReader.GetString(6);
			}
			if (dataReader.IsDBNull(7) == false) {
				tF_EventH.OwnerId = dataReader.GetInt32(7);
			}
			if (dataReader.IsDBNull(8) == false) {
				tF_EventH.CreateDate = dataReader.GetDateTime(8);
			}
			if (dataReader.IsDBNull(9) == false) {
				tF_EventH.TotalCost = dataReader.GetDouble(9);
			}
			if (dataReader.IsDBNull(10) == false) {
				tF_EventH.AttendCount = dataReader.GetInt32(10);
			}
			if (dataReader.IsDBNull(11) == false) {
				tF_EventH.StarNum = dataReader.GetInt32(11);
			}
			if (dataReader.IsDBNull(12) == false) {
				tF_EventH.PublicType = dataReader.GetString(12);
			}
			if (dataReader.IsDBNull(13) == false) {
				tF_EventH.StartCityId = dataReader.GetInt32(13);
			}
			if (dataReader.IsDBNull(14) == false) {
				tF_EventH.EventCities = dataReader.GetString(14);
			}
			if (dataReader.IsDBNull(15) == false) {
				tF_EventH.AttentionCount = dataReader.GetInt32(15);
			}

			return tF_EventH;
		}
		#endregion
	}
}
